<template>
  <!--电影详情-->
  <van-nav-bar
    title="详情页"
    left-text="返回"
    left-arrow
    @click-left="onClickLeft"
  />
  <div class="top-img">
    <img :src="detailInfo.pic" />
  </div>
  <div class="movie-detail-info">
    <div class="rating-box">
      <div class="movie-title">{{ detailInfo.title }}</div>
      <div class="movie-rating">{{ detailInfo.rating + "分" }}</div>
    </div>
    <div class="movie-item">
      <div class="movie-item-label">电影标语：</div>
      <div>{{ detailInfo.slogo }}</div>
    </div>
    <div class="movie-item">
      <div class="movie-item-label">电影标签：</div>
      <div class="tag-list">
        <span
          v-for="(item, index) in detailInfo.labels"
          class="tag-item"
          :key="index"
          >{{ item }}</span
        >
      </div>
    </div>
    <div class="btn-box">
      <div class="btn-buy">选座购票</div>
    </div>
  </div>
</template>
<script setup>
import { useRoute } from "vue-router";
const route = useRoute();
import { onMounted, ref } from "vue";
import router from "../router";

const detailInfo = ref(new Object());
onMounted(async () => {
  //获取城市列表信息
  const tempData = await fetch(
    "http://122.112.161.135:4000/api/movieDetail?id=" + route.query.id
  ).then((data) => data.json());
  detailInfo.value = tempData.res[0];
});
function onClickLeft() {
  router.push("/");
}
</script>
<style>
.movie-detail-info {
  padding: 0px 20px;
  box-sizing: border-box;
}
.top-img {
  display: flex;
  justify-content: center;
  height: 300px;
  margin-top: 10px;
}
.rating-box {
  padding: 0px 20px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}
.movie-title {
  font-size: 18px;
}
.movie-rating {
  color: #ffb26d;
  font-size: 14px;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
  font-weight: bold;
}
.movie-item {
  display: flex;
  margin-top: 10px;
}
.movie-item-label {
  color: #797d82;
  font-size: 14px;
}
.tag-list {
  display: flex;
  font-size: 12px;
}
.tag-item {
  font-size: 10px;
  width: 64px;
  background-color: #eebb81;
  color: #fff;
  padding: 2px 4px;
  box-sizing: border-box;
  border-radius: 20px;
  text-align: center;
  margin-right: 8px;
  height: 22px;
  line-height: 18px;
}
.btn-box {
  display: flex;
  justify-content: center;
  margin-top: 100px;
}
.btn-buy {
  background-color: #ff5f16;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: #fff;
  width: 80%;
  border-radius: 6px;
}
.detail-nav-top {
  display: flex;
  height: 40px;
  line-height: 40px;
  text-align: center;
  width: 100%;
}
</style>
